﻿@model UserAccountModel
@{
    ViewBag.Title = "编辑用户账户";
}
<div class="bs-docs-header" id="content" tabindex="-1">
    <div class="container">
        <p>发邮件给我们：<a href="mailto:minguiluo@163.com">minguiluo@163.com</a></p>
    </div>
</div>
<div class="container bs-docs-container">
    <hgroup class="title">
        <h3>@Html.Image("User_32.png")&nbsp;@ViewBag.Title</h3>
    </hgroup>


    @using (Html.BeginForm("EditUserAccount", "Admin", FormMethod.Post, new { id = "EditUserAccountForm" }))
    {
        @Html.ValidationSummary(true)

        @Html.HiddenFor(model => model.ID)

        <div class="editor-label">
            @Html.LabelFor(model => model.UserName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.UserName)
            @Html.ValidationMessageFor(model => model.UserName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Email)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Email)
            @Html.ValidationMessageFor(model => model.Email)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Role.Name)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.Role.ID, (IEnumerable<SelectListItem>)ViewData["roles"])
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.IsDisabled)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.IsDisabled)
            @Html.ValidationMessageFor(model => model.IsDisabled)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.DateRegisteredStr)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.DateRegisteredStr, new { disabled = true })
            @Html.ValidationMessageFor(model => model.DateRegistered)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.DateLastLogonStr)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.DateLastLogonStr, new { disabled = true })
            @Html.ValidationMessageFor(model => model.DateLastLogon)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Contact)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Contact)
            @Html.ValidationMessageFor(model => model.Contact)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.PhoneNumber)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.PhoneNumber)
            @Html.ValidationMessageFor(model => model.PhoneNumber)
        </div>

        <p />

        <table id="adressTable" style="width: 100%">
            <tr>
                <td style="width: 48%;">
                    <fieldset name="contactAddress">
                        <legend>联系地址</legend>
                        <div class="editor-label">
                            @Html.LabelFor(model => model.ContactAddress_Country)
                        </div>
                        <div class="editor-field">
                            @Html.EditorFor(model => model.ContactAddress_Country)
                            @Html.ValidationMessageFor(model => model.ContactAddress_Country)
                        </div>


                        <div class="editor-label">
                            @Html.LabelFor(model => model.ContactAddress_State)
                        </div>
                        <div class="editor-field">
                            @Html.EditorFor(model => model.ContactAddress_State)
                            @Html.ValidationMessageFor(model => model.ContactAddress_State)
                        </div>

                        <div class="editor-label">
                            @Html.LabelFor(model => model.ContactAddress_City)
                        </div>
                        <div class="editor-field">
                            @Html.EditorFor(model => model.ContactAddress_City)
                            @Html.ValidationMessageFor(model => model.ContactAddress_City)
                        </div>

                        <div class="editor-label">
                            @Html.LabelFor(model => model.ContactAddress_Street)
                        </div>
                        <div class="editor-field">
                            @Html.EditorFor(model => model.ContactAddress_Street)
                            @Html.ValidationMessageFor(model => model.ContactAddress_Street)
                        </div>

                        <div class="editor-label">
                            @Html.LabelFor(model => model.ContactAddress_Zip)
                        </div>
                        <div class="editor-field">
                            @Html.EditorFor(model => model.ContactAddress_Zip)
                            @Html.ValidationMessageFor(model => model.ContactAddress_Zip)
                        </div>
                    </fieldset>
                </td>
                <td>
                    <img id="copyAddress" src="@Url.Content("~/Images/CopyTo.png")" alt="将联系地址复制到收货地址" title="将联系地址复制到收货地址" border="0" />
                </td>
                <td style="width: 48%;">
                    <fieldset name="deliveryAddress">
                        <legend>收货地址</legend>
                        <div class="editor-label">
                            @Html.LabelFor(model => model.DeliveryAddress_Country)
                        </div>
                        <div class="editor-field">
                            @Html.EditorFor(model => model.DeliveryAddress_Country)
                            @Html.ValidationMessageFor(model => model.DeliveryAddress_Country)
                        </div>
                        <div class="editor-label">
                            @Html.LabelFor(model => model.DeliveryAddress_State)
                        </div>
                        <div class="editor-field">
                            @Html.EditorFor(model => model.DeliveryAddress_State)
                            @Html.ValidationMessageFor(model => model.DeliveryAddress_State)
                        </div>

                        <div class="editor-label">
                            @Html.LabelFor(model => model.DeliveryAddress_City)
                        </div>
                        <div class="editor-field">
                            @Html.EditorFor(model => model.DeliveryAddress_City)
                            @Html.ValidationMessageFor(model => model.DeliveryAddress_City)
                        </div>

                        <div class="editor-label">
                            @Html.LabelFor(model => model.DeliveryAddress_Street)
                        </div>
                        <div class="editor-field">
                            @Html.EditorFor(model => model.DeliveryAddress_Street)
                            @Html.ValidationMessageFor(model => model.DeliveryAddress_Street)
                        </div>

                        <div class="editor-label">
                            @Html.LabelFor(model => model.DeliveryAddress_Zip)
                        </div>
                        <div class="editor-field">
                            @Html.EditorFor(model => model.DeliveryAddress_Zip)
                            @Html.ValidationMessageFor(model => model.DeliveryAddress_Zip)
                        </div>
                    </fieldset>
                </td>
            </tr>
        </table>
    }

    <p />
    <p>
        <span>@Html.ImageSubmitButton("EditUserAccountForm", Url.Content("~/Images/Save.png"), "保存", "保存更改")</span>
        <span>&nbsp;</span>
        <span>@Html.ImageActionLink(Url.Content("~/Images/Cancel.png"), "取消编辑", "取消编辑", "UserAccounts", "Admin")</span>
    </p>


    @section scripts {
        <script type="text/javascript">
            $(function () {
                $("#UserName").focus();
                $("#copyAddress").click(function () {
                    $("#DeliveryAddress_Country").val($("#ContactAddress_Country").val());
                    $("#DeliveryAddress_State").val($("#ContactAddress_State").val());
                    $("#DeliveryAddress_City").val($("#ContactAddress_City").val());
                    $("#DeliveryAddress_Street").val($("#ContactAddress_Street").val());
                    $("#DeliveryAddress_Zip").val($("#ContactAddress_Zip").val());
                });
            });
        </script>
    }
</div>